package com.sinosoft.dsp.component.bpm.viewbean.activity.part;

import org.jbpm.xsdobject.Process;

import com.sinosoft.dsp.component.bpm.util.ProcessParse;
import com.sinosoft.dsp.component.bpm.viewbean.BpmJpdlDefineViewBean;
import com.sinosoft.dsp.component.bpm.viewbean.activity.IBpmActivityPartEditViewBean;
import com.sinosoft.dsp.system.core.exception.SinoException;
import com.sinosoft.dsp.system.to.IGenericTO;
import com.sinosoft.dsp.system.to.attribute.Attribute;
import com.sinosoft.dsp.system.to.helper.ToHelper;
import com.sinosoft.dsp.system.utils.Const;

public class BpmActivitySubBaseViewBean extends BpmActivityCommonBaseViewBean
		implements IBpmActivityPartEditViewBean {

	// 子流程ID(Long)
	public static final String FIELD_SUB_PROCESS_ID = "subProcessId";

	// 子流程KEY
	public static final String FIELD_SUB_PROCESS_KEY = "subProcessKey";

	// 执行表达式
	public static final String FIELD_SUB_OUTCOME = "outcome";

	@Override
	public void init(IGenericTO tos) throws SinoException {
		super.init(tos);

		// 活动对象
		Attribute<?> name = ToHelper.getContentAttriubteByName(tos,
				BPM_NODE_NAME);
		String nameStr = name.convertToString();

		BpmJpdlDefineViewBean pvb = (BpmJpdlDefineViewBean) this.getParent()
				.getParent();
		org.jbpm.xsdobject.Process process = pvb.getProcess();
		Process.SubProcess obj = (Process.SubProcess) ProcessParse.getActivity(
				process, nameStr);

		this.addField(FIELD_SUB_PROCESS_ID, Const
				.NVL(obj.getSubProcessId(), ""));
		this.addField(FIELD_SUB_PROCESS_KEY, Const.NVL(obj.getSubProcessKey(),
				""));
		this.addField(FIELD_SUB_OUTCOME, Const.NVL(obj.getOutcome(), ""));
	}

}
